#pragma once
#include "GoogleProtocol.h"
#include "GoogleUserData.h"
#include "GoogleContact.h"

namespace GoogleProtocol
{

class CGoogleEntry
{
public:
	CGoogleEntry(void);

public:
	//-------------------------------------------------------------------
	//  Description:      Get Google Entry Instance.
	//
	//  Return:
	//                    Unique Instance.
	//-------------------------------------------------------------------
	static CGoogleEntry* GetInstance();

	//-------------------------------------------------------------------
	//  Description:      Free Google Entry Instance.
	//
	//  Return:
	//                    Unique Instance.
	//-------------------------------------------------------------------
	static void FreeInstance();

public:
	//-------------------------------------------------------------------
	//  Description:      Login to google server.
	//
	//  Parameter:
	//      lpIPAddr:     Receives server' ip address.
	//      lpUserName:   User Account.
	//      lpPassword:   User Password.
	//
	//  Return:
	//       1            Succeed.
	//       0            Failed.
	//      -1            Http request error;
	//      -2            Authorization error.
	//      -3            Account Id or password error.
	//-------------------------------------------------------------------
	LRESULT LogIn(LPCSTR lpUserName, LPCSTR lpPassword);

	//-------------------------------------------------------------------
	//  Description:     Logout from google server.
	//
	//  Parameter:
	//
	//  Return:
	//      1            Succeed.
	//      0            Failed.
	//-------------------------------------------------------------------
	LRESULT LogOut();

	//-------------------------------------------------------------------
	//  Description:      Set server ip address to google contact.
	//
	//  Parameter:
	//      lpEntryName:  Server's name.
	//      lpIPAddr:     New server' ip address.
	//
	//  Return:
	//       2            Added succeed.
	//       1            Update succeed.
	//       0            Failed.
	//      -1            Http request error;
	//      -2            Authorization error.
	//      -3            Account Id or password error.
	//-------------------------------------------------------------------
	LRESULT SetIP(LPCSTR lpEntryName, LPCSTR lpIPAddr);

	//-------------------------------------------------------------------
	//  Description:      Get server ip address from google contact.
	//
	//  Parameter:
	//      lpEntryName:  Server's name.
	//      lpIPAddr:     Receives server' ip address.
	//
	//  Return:
	//       1            Succeed.
	//       0            Failed.
	//      -1            Http request error;
	//      -2            Authorization error.
	//      -3            Account Id or password error.
	//-------------------------------------------------------------------
	LRESULT GetIP(LPCSTR lpEntryName, LPSTR lpIPAddr);
	//-------------------------------------------------------------------
	//  Description:     Get UserName
	//
	//  Parameter:
	//                   [OUT] UserName
	//  Return:
	//      1            Succeed.
	//      0            Failed.
	//-------------------------------------------------------------------
	LRESULT GetUserName(LPWSTR lpUserName);
	//-------------------------------------------------------------------
	//  Description:     Get UserPassword
	//
	//  Parameter:
	//                   [OUT] UserPwd
	//  Return:
	//      1            Succeed.
	//      0            Failed.
	//-------------------------------------------------------------------
	LRESULT GetUserPwd(LPWSTR lpUserPwd);

protected:
	~CGoogleEntry(void);

private:
	static CGoogleEntry*   m_pUniqueInst;
	CGoogleContact         m_contact;
	CGoogleUserData        m_userdata;
};

}